package org.mspring.mlog.action.blog;

import org.mspring.mlog.common.ErrorCode;
import org.mspring.mlog.entity.User;
import org.mspring.mlog.security.SecurityService;
import org.mspring.mlog.service.WeiboService;
import org.mspring.nbee.web.Action;
import org.mspring.nbee.web.support.WebContext;
import org.mspring.nbee.web.view.json.JsonResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 微博相关接口
 *
 * @author GaoYoubo
 * @since 2015/2/21
 */
@Action("blogWeiboAction")
@RequestMapping("/weibo")
public class WeiboAction {

    private WeiboService weiboService;
    private SecurityService securityService;

    @RequestMapping({"/index", "/", ""})
    public String index(WebContext context, Model model) {
        return "theme:/weibo";
    }

    @RequestMapping("/list")
    public void list(WebContext context, Model model) {

    }

    @RequestMapping("/create")
    public void create(WebContext context, Model model) {
        User currentUser = securityService.getCurrentUser(context.getRequest());
        if (currentUser == null) {
            context.renderJsonResult(JsonResultUtils.failure(ErrorCode.AUTH_NOT_LOGIN));
            return;
        }
    }

    @Autowired
    public void setWeiboService(WeiboService weiboService) {
        this.weiboService = weiboService;
    }

    @Autowired
    public void setSecurityService(SecurityService securityService) {
        this.securityService = securityService;
    }
}
